package com.wlyuan.open.scanner.application.handler.full;

import com.wlyuan.open.dto.OpenTemplateSyncDTO;
import com.wlyuan.open.scanner.application.annotation.ScannerCode;
import com.wlyuan.open.scanner.assembler.ScannerTemplateAssembler;
import com.wlyuan.open.scanner.constant.ScannerCodeEnum;
import com.wlyuan.open.scanner.domain.template.Template;
import com.wlyuan.open.scanner.repository.TemplateRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lijing
 * @description
 */
@ScannerCode(code = ScannerCodeEnum.TEMPLATE)
@Service
@Slf4j
@RequiredArgsConstructor
public class ScannerTemplateHandler extends BaseScannerHandler<Template, OpenTemplateSyncDTO> {
    private final TemplateRepository templateRepository;

    @Override
    protected List<Template> select() {
        return templateRepository.list();
    }

    @Override
    protected List<OpenTemplateSyncDTO> assembler(List<Template> data) {
        return ScannerTemplateAssembler.assemble(data);
    }
}
